﻿namespace ETestIT.UI.AppControls
{
    using System;
    using System.Web.UI;
    using Domain.Entities;

    public partial class CandidateAddUpdate : UserControl
    {
        public event EventHandler Save;

        public void SetModel(Candidate candidate)
        {
            tbTitle.Text = candidate.Title;
            tbFirstName.Text = candidate.FirstName;
            tbSurename.Text = candidate.Surename;
        }

        public void UpdateModel(Candidate candidate)
        {
            candidate.Title = tbTitle.Text.Trim();
            candidate.FirstName = tbFirstName.Text.Trim();
            candidate.Surename = tbSurename.Text.Trim();
        }

        protected void bntSave_Clicked(object sender, EventArgs e)
        {
            if (Save != null)
                Save(sender, e);
        }
    }
}